package com.hdc.lw.word_server.service;

import com.hdc.lw.word_server.mapper.CollectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class CollectService {

    @Autowired
    private CollectMapper collectMapper;

    public Map collectWord(Integer uid, Integer wid){
        Map<String,Object> map = new HashMap<>();
        int row = collectMapper.collectWord(uid,wid);
        if(row>0){
            map.put("code",200);
            map.put("msg","收藏单词成功！");
        }else {
            map.put("code",301);
            map.put("msg","收藏单词失败！");
        }
        return map;
    }

    public Map delCollectWord(Integer uid,Integer wid){
        Map<String,Object> map = new HashMap<>();
        int row = collectMapper.delCollectWord(uid,wid);
        if(row>0){
            map.put("code",200);
            map.put("msg","取消收藏单词成功！");
        }else {
            map.put("code",301);
            map.put("msg","取消收藏单词失败！");
        }
        return map;
    }
}
